package com.hollycrm.unicom.usersupport;

import com.hollycrm.unicom.common.TreeViewObject;

/**
 *
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author Tian Kai
 * @version 1.0
 */

public class DepartmentTreeViewObject
    extends TreeViewObject {

    private String departmentID;
    private String deptType;

    public DepartmentTreeViewObject(String departmentID, String deptType,
                                    String id, String name,
                                    String isLeaf, int level) {
        this.departmentID = departmentID;
        this.deptType = deptType;

        super.id = departmentID;
        super.name = name;

        if ("1".equals(isLeaf)) {
            super.type = TreeViewObject.NO_SUB_NODE;
        }
        else {
            super.type = TreeViewObject.HAS_SUB_NODE;
        }

        super.level = level;
    }

    public String getSendType() {
        if (Department.TYPE_TWO.equals(deptType))
            return "02";
        else
            return "01";

    }

    public int hashCode() {
        return id == null ? super.hashCode() : id.hashCode();
    }

    public boolean equals(Object o) {
        return o instanceof DepartmentTreeViewObject && id != null &&
            id.equals( ( (DepartmentTreeViewObject) o).getId());
    }

    public String getDepartmentID() {
        return departmentID;
    }
    public void setDepartmentID(String departmentID) {
        this.departmentID = departmentID;
    }
    public String getDeptType() {
        return deptType;
    }
    public void setDeptType(String deptType) {
        this.deptType = deptType;
    }

}
